<template>
  <div class="divBox relative">
    <el-card class="box-card">
      <div class="clearfix">
        <div class="container">
          <el-form size="small" label-width="100px">
            <el-row>
              <el-col :span="8">
                <el-form-item label="商铺：" class="width100">
                  <el-input v-model="tableFrom.shopsName" placeholder="请输入商铺" class="selWidth" size="small"
                            clearable>
                    <el-button slot="append" icon="el-icon-search" size="small" @click="seachList"/>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="类别：" class="width100">
                  <el-select v-model="tableFrom.category" placeholder="请选择" class="selWidth" @change="seachList" clearable>
                    <block v-for="item in classifys">
                      <el-option :label="item.classify" :value="item.classifyNum"></el-option>
                    </block>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>
      </div>
    </el-card>
    <div class="mt20">
    </div>
    <el-card class="box-card">
      <el-table v-loading="listLoading" :data="tableData.data" size="mini" class="table" highlight-current-row
                :header-cell-style="{ fontWeight: 'bold' }">
        <el-table-column prop="shopsName" label="商铺" min-width="150"/>
        <el-table-column prop="category" label="类别" min-width="150"/>
        <el-table-column prop="address" label="地址" min-width="150"/>
        <el-table-column prop="weixin" label="微信号" min-width="150"/>
        <el-table-column label="操作" min-width="150" fixed="right" align="center">
          <template slot-scope="scope">
            <router-link :to="{ path: '/customerAcquisition/business/detail/' + scope.row.id }">
              <el-button type="text" size="small" class="mr10">详情</el-button>
            </router-link>
          </template>
        </el-table-column>
      </el-table>
      <div class="block">
        <el-pagination :page-sizes="[20, 40, 60, 80]" :page-size="tableFrom.limit" :current-page="tableFrom.page"
                       layout="total, sizes, prev, pager, next, jumper" :total="tableData.total"
                       @size-change="handleSizeChange"
                       @current-change="pageChange"/>
      </div>
    </el-card>
  </div>
</template>

<script>
import {businessListApi, getClassifysApi} from '@/api/business'

export default {
  name: 'BusinessIndex',
  components: {},
  data() {
    return {
      tableData: {
        data: [],
        total: 0
      },
      listLoading: true,
      tableFrom: {
        "limit": 10,
        "page": 1,
        "category": '',
        "shopsName": ''
      },
      classifys:[]  // 类别
    }
  },
  mounted() {
    this.getList();
    this.getClassifys();  //  获取类别
  },
  methods: {
    resetForm(formValue) {
      this.dialogVisible = false
    },
    seachList() {
      this.tableFrom.page = 1
      this.getList()
    },
    // 获取订单列表
    getList() {
      this.listLoading = true
      businessListApi(this.tableFrom).then(res => {
        this.tableData.data = res.list || [];
        this.tableData.total = res.total;
        this.listLoading = false
      }).catch(() => {
        this.listLoading = false
      })
    },
    pageChange(page) {
      this.tableFrom.page = page
      this.getList()
    },
    handleSizeChange(val) {
      this.tableFrom.limit = val
      this.getList()
    },
    //  获取类别
    getClassifys() {
      getClassifysApi().then(res => {
        this.classifys = res
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.el-table__body {
  width: 100%;
  table-layout: fixed !important;
}

.demo-table-expand {
  ::v-deeplabel {
    width: 83px !important;
  }
}

.refunding {
  span {
    display: block;
  }
}

.selWidth {
  width: 300px;
}

.el-dropdown-link {
  cursor: pointer;
  color: #409EFF;
  font-size: 12px;
}

.el-icon-arrow-down {
  font-size: 12px;
}

.tabBox_tit {
  font-size: 12px !important;
  /*margin: 0 2px 0 10px;*/
  letter-spacing: 1px;
  /*padding: 5px 0;*/
  box-sizing: border-box;
}

.text_overflow {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.pup_card {
  width: 200px;
  border-radius: 5px;
  padding: 5px;
  box-sizing: border-box;
  font-size: 12px;
  line-height: 16px;
}

.flex-column {
  display: flex;
  flex-direction: column;
}

.mt20 {
  margin-top: 20px
}

.relative {
  position: relative;
}
</style>
